package com.imooc.api.controller.files;

import com.imooc.grace.result.GraceJSONResult;
import com.imooc.pojo.bo.NewAdminBO;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Description : 文件上传Controller
 * @Author : YTY
 * @Date : 2020-12-01 17:33
 */

@Api(value = "文件上传Controller", tags = {"文件上传Controller"})
@RequestMapping("fs")
public interface FileUploaderControllerApi {

    /**
     * 上传单文件
     */
    @PostMapping("/uploadFace")
    public GraceJSONResult uploadFace(
            @RequestParam String userId,
            MultipartFile file) throws Exception;

    /**
     * 上传多文件
     */
    @PostMapping("/uploadSomeFiles")
    public GraceJSONResult uploadSomeFiles(
            @RequestParam String userId,
            MultipartFile[] files) throws Exception;

    /**
     * 文件上传到MongoDB的gridfs中
     */
    @PostMapping("/uploadToGridFS")
    public GraceJSONResult uploadToGridFS(@RequestBody NewAdminBO newAdminBO) throws Exception;

    /**
     * 从GridFS中读取图片内容
     */
    @GetMapping("/readInGridFS")
    public void readInGridFS(String faceId,
                             HttpServletRequest request,
                             HttpServletResponse response) throws Exception;

    /**
     * 从GridFS中读取图片内容，并返回Base64
     */
    @GetMapping("/readFace64InGridFS")
    public GraceJSONResult readFace64InGridFS(String faceId,
                             HttpServletRequest request,
                             HttpServletResponse response) throws Exception;

}
